﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Media.Imaging;

namespace FoodMatch
{
    class GameState
    {
        private RandomGenerator rg;
        private List<string> pos;
        private List<bool> state;
        private List<BitmapImage> img;

        public GameState()
        {
            rg = new RandomGenerator();
            pos = new List<string>();
            state = new List<bool>();
            img = new List<BitmapImage>();
        }

        public BitmapImage generateImg()
        {
            BitmapImage image = rg.generateImg();
            return image;
        }

        public int generateNum()
        {
            int imageNum = rg.generateNum();
            return imageNum;
        }

        public string generatePosition()
        {
            string imagePosition = rg.generatePosition();
            return imagePosition;
        }

        public bool checkExistence(string name)
        {
            int index = pos.IndexOf(name);
            return getState(index);
        }

        public void clear(string name)
        {
            int index = pos.IndexOf(name);
            if (state[index])
                state[index] = false;
        }

        public bool getState(int index)
        {
            return state[index];
        }

        public void modifyState(int index)
        {
            state[index] = false;
        }

        public void initialization()
        {
            for (int i = 0; i < 84; i++)
            {
                this.pos[i] = this.rg.generatePosition();
                this.state[i] = true;
                this.img[i] = this.rg.generateImg();
            }
        }
    } 
}
